import Vue from "vue";
import Router from "vue-router";
import Layout from "../layout/index";

Vue.use(Router);

export const constantRouterMap = [
  // {
  //   path: "/home",
  //   meta: { title: "首页", noCache: true },
  //   component: (resolve) => require(["@/views/home"], resolve),
  //   hidden: true,
  // },
  {
    path: "/home2",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "/home2",
        component: (resolve) => require(["@/views/home2"], resolve),
        name: "home2",
        meta: { title: "副屏", icon: "index", affix: true, noCache: true },
      },
    ],
  },

  {
    path: "/merchantManagement/merchantBattery/details",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "/merchantManagement/merchantBattery/details",
        component: (resolve) =>
          require([
            "@/views/merchantManagement/merchantBattery/details",
          ], resolve),
        name: "batteryDetails",
        meta: { title: "电池详情", icon: "index", affix: true, noCache: true },
      },
    ],
  },
  // {
  //   path: "/merchantManagement/merchantBattery/test",
  //   component: Layout,
  //   hidden: true,
  //   redirect: "noredirect",
  //   children: [
  //     {
  //       path: "/merchantManagement/merchantBattery/test",
  //       component: (resolve) =>
  //         require(["@/views/merchantManagement/merchantBattery/test"], resolve),
  //       name: "test",
  //       meta: { title: "测试", icon: "index", affix: true, noCache: true },
  //     },
  //   ],
  // },

  {
    path: "/login",
    meta: { title: "登录", noCache: true },
    component: (resolve) => require(["@/views/login"], resolve),
    hidden: true,
  },
  {
    path: "/404",
    component: (resolve) => require(["@/views/features/404"], resolve),
    hidden: true,
  },
  {
    path: "/401",
    component: (resolve) => require(["@/views/features/401"], resolve),
    hidden: true,
  },
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path*",
        component: (resolve) => require(["@/views/features/redirect"], resolve),
      },
    ],
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        component: (resolve) => require(["@/views/home"], resolve),
        name: "Dashboard",
        meta: { title: "首页", icon: "index", affix: true, noCache: true },
      },
    ],
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "center",
        component: (resolve) =>
          require(["@/views/system/user/center"], resolve),
        name: "个人中心",
        meta: { title: "个人中心" },
      },
    ],
  },
];

export default new Router({
  // mode: 'hash',
  mode: "history",
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap,
});
